export function getDateTime() {
    let today = new Date();
    let hour = today.getHours();
    let min = today.getMinutes();
    let second = today.getSeconds();
    let y = today.getFullYear();
    let m = today.getMonth() + 1;
    let d = today.getDate();
    let w = today.getDay();
    if (hour < 10) hour = '0' + hour;
    if (min < 10) min = '0' + min;
    if (second < 10) second = '0' + second;
    if (m < 10) m = '0' + m;
    if (d < 10) d = '0' + d;

    switch (w) {
        case 0:
            w = '星期日';
            break;
        case 1:
            w = '星期一';
            break;

        case 2:
            w = '星期二';
            break;

        case 3:
            w = '星期三';
            break;

        case 4:
            w = '星期四';
            break;

        case 5:
            w = '星期五';
            break;

        case 6:
            w = '星期六';
            break;
        default:
            w = '';
    }

    return {
        date: y + '年' + m + '月' + d + '日',
        time: hour + ':' + min + ':' + second,
        week: w
    }
}

export function formatDate() {
    let today = new Date();

    let y = today.getFullYear();
    let m = today.getMonth() + 1;
    let d = today.getDate();
    
    if (m < 10) m = '0' + m;
    if (d < 10) d = '0' + d;

    return y + '-' + m + '-' + d
}